<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>手机验证-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" href="__STATIC__/css/index.css" type="text/css">
    <script src="__STATIC__/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/slider.js"></script>
	<script src="__PUBLIC__/js/global.js"></script>
    <script src="__PUBLIC__/js/pc_common.js"></script>
	<script src="__PUBLIC__/js/layer/layer.js"></script><!--弹窗js 参考文档 http://layer.layui.com/-->        

</head>

<body>
<!--------头部开始-------------->
<include file="Public/header" />
<!--------头部结束-------------->

    <div class="breadcrumb-area">    
<div class="layout">
	    <foreach name="navigate_user" key="k" item="v">
	        <if condition="$k neq '首页'"> > </if>  
            <a href="{$v}">{$k}</a> 
        </foreach>
    </div>
</div>
<div class="layout pa-to-10 fo-fa-ar">
    <!--菜单-->
    <include file="User/menu" />
    <!--菜单-->
    <div class="fr wi872">  <div class="he50 wddd">
            <div class="fl ddd-h2">
                <h2><span>绑定手机</span></h2>
            </div>
        </div>
        <div class="xgzl-w ta-tldf">
            <form action="" method="post" onSubmit="return check_form();">
                <table>
                    <tbody>
                    <!--步骤二 验证新手机号码-->
                    <notempty name="user_info.mobile">
                    <tr>
                        <td class="cl_left" align="right">原手机：</td>
                        <td>
                                    <div class="dv_cell_left">
                            <input type="text" class="imput_text text_width foce" id="old_mobile" value="{$user_info['mobile']}" name="old_mobile" readonly="readonly"
                                   style="cursor: not-allowed;color:#999" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')"  /></div>
                        </td>
                        <td>
                            <span id="msg_txtMailAccount"></span>
                        </td>
                    </tr>
                   </notempty>
                    <tr>
                        <td class="cl_left" align="right">新手机：</td>
                        <td>
						
                                    <div class="dv_cell_left">
                            <input type="text" class="imput_text text_width foce" id="new_mobile" name="mobile"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" /></div>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="cl_left">
                            	验证码：
                        </td>
                        <td class="cl_middle">
                                    <div class="dv_cell_left">
                            <input type="text" id="new_code" maxlength="4" style="width:100px;" class="imput_text" name="code">
                            <input type="button" class="box-ok" intervaltime="{$time}" value="获取验证码 " id="btnemailAuthCode2" onClick="sendCode(this,'new_mobile')">
							</div>
                        </td>
                    </tr>

                    <!--步骤二 验证新手机号码结束-->
                    <tr class="tr_height">
						<td></td>
                        <td valign="middle" align="left" colspan="2" >
                            <input type="submit" value="下一步" class="btn_midefy" id="btn_next">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3"></td>
                    </tr>
                    </tbody>
                </table>
            </form>

        </div>
    </div>
</div>
<div class="he80"></div>
<!--------footer-开始-------------->
<include file="Public/footer" />
<!--------footer-结束-------------->
<script>
	// 表单提交验证
	function check_form()
	{
        var old_mobile = $('#old_mobile').val();		
        var new_mobile = $('#new_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});// alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(new_mobile)){
            layer.alert('新手机格式错误', {icon: 2});//alert('新手机格式错误');
            return false;
        }	
		
		if($.trim($('#new_code').val()) == '')	
		{
            layer.alert('验证码不能为空', {icon: 2});//alert('验证码不能为空');
            return false;			
		}
		return true;
	} 
    function sendCode(obj,input_id){
        var id = $(obj).attr('id');
        var input = $('#'+input_id).val();
        var old_mobile = $('#old_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});//alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(input)){
            layer.alert('手机号码格式错误', {icon: 2});//alert('手机号码格式错误');
            return false;
        }
        if(input_id == 'old_mobile')
            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=1&type=mobile&send="+input;
        if(input_id == 'new_mobile')
            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=2&type=mobile&send="+input;
        //发送验证码
        $.ajax({
            type : "GET",
            url  : url,
            dataType : 'json',
            error: function(request) {
                layer.alert('服务器繁忙, 请联系管理员!', {icon: 2});//alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(res) {
                if(res.status == 1){
                    jsInnerTimeout(id);
                }else{
                    layer.alert(res.msg,{icon: 2});//alert('发送失败');
                }
            }
        });
    }

    //倒计时函数
    function jsInnerTimeout(id)
    {
        var codeObj=$("#"+id);
        var intAs=parseInt(codeObj.attr("IntervalTime"));

        intAs--;
        codeObj.attr("disabled","disabled");
        if(intAs<=-1)
        {
            codeObj.removeAttr("disabled");
            codeObj.attr("IntervalTime",{$time});
            codeObj.val("获取验证码");
            return true;
        }

        codeObj.val(intAs+'s后再次获取');
        codeObj.attr("IntervalTime",intAs);

        setTimeout("jsInnerTimeout('"+id+"')",1000);
    };

</script>
</html>